<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<title></title>
<link type="text/css" rel="stylesheet" href="css/style1.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
    <link rel="stylesheet" href="plugins/elementui/index.css" />

<script type="text/javascript">
$(document).ready(function () {
   var height=$(document).height();
   $('body').css('height',height);
   var mart=height-500;
   mart = mart/2;
   $('.loginBox').css('marginTop',mart);
})
</script>
</head>

<body>
<div class="app" id="app">
    <div class="loginBox">
        <form id='login-form'>
            <h1>找回密码</h1>
            <div class="item">
              <div class="icon"><img src="images/icon1.png" /></div>
              <div class="txt"><input v-model="loginInfo.telephone" id='account' type="text" placeholder="请输入手机号"/></div>
            </div>
            <div class="item">
              <div class="icon"><img src="images/icon3.png" /></div>
              <div class="txt"><input v-model="loginInfo.validateCode" style="width:80%" id='code' type="text" placeholder="请输入验证码"/></div>
              <input id="validateCodeButton" @click="sendValidateCode()" type="button" style="font-size: 12px" value="获取验证码">
            </div>
            <div class="item">
              <div class="icon"><img src="images/icon1.png" /></div>
              <div class="txt"><input v-model="loginInfo.password" id='password' type="text" placeholder="请输入新登录密码"/></div>
            </div>
            <div class="item">
              <div class="icon"><img src="images/icon1.png" /></div>
              <div class="txt"><input v-model="loginInfo.password1" id='password2' type="text" placeholder="请再次输入新密码"/></div>
            </div>
            <div class="item_3">
                <input name="" type="submit" value="确认" class="btn"  @click="submitPassword()"/>
            </div>
        </form>
    </div>
</div>
</body>
<script src="plugins/healthmobile.js"></script>
<script src="js/vue.js"></script>
<script src="plugins/vue/axios-0.18.0.js"></script>
<script src="plugins/elementui/index.js"></script>
<script>
    let vue = new Vue({
        el:'#app',
        data:{
            loginInfo:{}//登录信息
        },
        methods: {
            //发送验证码
            sendValidateCode() {
                let telephone = this.loginInfo.telephone;
                if (!checkTelephone(telephone)) {
                    this.$message.error('请输入正确的手机号');
                    return false;
                }
                validateCodeButton = $("#validateCodeButton")[0];
                clock = window.setInterval(doLoop, 1000); //一秒执行一次
                axios.post("/validateCode/send4Login.do?telephone=" + telephone).then((response) => {
                    if (!response.data.flag) {
                        //验证码发送失败
                        this.$message.error('验证码发送失败，请检查手机号输入是否正确');
                    }
                });
            },
            //
            submitPassword() {
                let telephone = this.loginInfo.telephone;
                if (!checkTelephone(telephone)) {
                    this.$message.error('请输入正确的手机号');
                    return false;
                }

                // if (this.loginInfo.password !=this.loginInfo.password2){
                //     this.$message.error('两次输入的密码不相同,请重新输入');
                //     return false;
                // }
                // if (!checkPassword(this.loginInfo.password)){
                //     this.$message.error('密码格式输入错误,请输入至少6位字母或数字');
                //     return false;
                // }
                let param={
                    telephone:telephone,
                    password:this.loginInfo.password
                }
                axios.post("/user/password.do?validateCode=" + this.loginInfo.validateCode, param).then((res) => {
                    alert(222222222222);
                    if (res.data.flag) {
                        alert("111111111")
                        //登录成功,跳转到index.html
                        window.location.href = "success.html";
                    } else {
                        //失败，提示失败信息
                        this.$message.error(res.data.message);
                    }

                });
            }
        }
    });
</script>
</html>
